added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / VBASPNETAJAXImagePreviewExtender / ImagePreviewExtender / ImagePreviewControl.vb
blob266b197959fb36d391c3dbbe2b37a60bdb52018d
1 '***************************** Module Header ******************************\
2 '* Module Name: ImagePreviewControl.cs
3 '* Project: VBASPNETImagePreviewExtender
4 '* Copyright (c) Microsoft Corporation
5 '*
6 '* The project illustrates how to design an AJAX Control Extender.
7 '* In this sample, it is extender for images.
8 '* The images which use the extender control will show in a thumbnail mode at
9 '* first, if user click the image, a big image will pop up and show the true
10 '* size of the image.
11 '*
12 '* This source is subject to the Microsoft Public License.
13 '* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
14 '* All other rights reserved.
16 '\****************************************************************************
18 <TargetControlType(GetType(Control))> _
19 Public Class ImagePreviewControl
20 Inherits ExtenderControl
22 ''' <summary>
23 ''' Define the css class which the image use in thumbnail mode.
24 ''' </summary>
25 Public Property ThumbnailCssClass() As String
26 Get
27 Return m_ThumbnailCssClass
28 End Get
29 Set(ByVal value As String)
30 m_ThumbnailCssClass = value
31 End Set
32 End Property
33 Private m_ThumbnailCssClass As String
35 ''' <summary>
36 ''' return the resource url of the close icon.
37 ''' </summary>
38 Private ReadOnly Property closeImage() As String
39 Get
40 Return Page.ClientScript.GetWebResourceUrl(Me.[GetType](), "ImagePreviewExtender.Close.png")
41 End Get
42 End Property
44 Protected Overrides Function GetScriptDescriptors(ByVal targetControl As System.Web.UI.Control) As IEnumerable(Of ScriptDescriptor)
45 Dim descriptor As New ScriptBehaviorDescriptor("ImagePreviewExtender.ImagePreviewBehavior", targetControl.ClientID)
46 descriptor.AddProperty("ThumbnailCssClass", ThumbnailCssClass)
48 descriptor.AddProperty("closeImage", closeImage)
49 Return New List(Of ScriptDescriptor) From {descriptor}
50 End Function
52 ' Generate the script reference
53 Protected Overrides Function GetScriptReferences() As IEnumerable(Of ScriptReference)
54 Dim scriptRef As New ScriptReference("ImagePreviewExtender.ImagePreviewBehavior.js", Me.GetType().Assembly.FullName)
56 Return New List(Of ScriptReference) From {scriptRef}
57 End Function
58 End Class